package com.hq.vieorecyclerview.video.Adapter;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hq.vieorecyclerview.R;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * 首页视频信息适配
 */
public class VideoMessageAdapter extends RecyclerView.Adapter<VideoMessageHolder> {
    private final List<VideoDate> list;
    //视频数据保存实力
    private VideoModel model = null;

    public VideoMessageAdapter(VideoModel model) {
       // this.model = model;
       // this.model.update();
        list = new ArrayList<>();
        //图片更新
        String gif = "https://5b0988e595225.cdn.sohucs.com/images/20190721/67d2edceaecf4fa690c9a37fe37ddb40.gif";
        for (int i = 0; i < 100; i++) {
            VideoDate td = new VideoDate();
            td.setName("干嘛");
            td.setPlaytemp("2:34:44");
            td.setImage(gif);
            list.add(td);
        }
    }

    @NonNull
    @NotNull
    @Override
    public VideoMessageHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
        View v = View.inflate(parent.getContext(), R.layout.video_item_message, null);
        return new VideoMessageHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull VideoMessageHolder holder, int position) {

        //数据绑定
        holder.update(list.get(position));
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
